/**
 * ===============================================
 *  Created by ly on 2015/1/20.
 *  应用通用js，初始化应用配置，应用公共方法
 * 依赖require.js插件
 * ===============================================
 */
;

"use strict";

/**
 * -----------------------------------------------
 * 应用初始化配置
 * -----------------------------------------------
 */
/**
 * 配置信息
 * @type {{token: string, loginUrl: string, appKey: string, secretKey: string, adminSignUrl: string, adminServerUrl: string, rootUrl: string, indexUrl: string}}
 */
var configs = {
  loginUrl: "/admin/login.html",
  //appKey: "7176384017",
  appKey: "9909756346",
  //secretKey: "d2b0a7a95dcfbf0cac630ba34cb73de8",
  secretKey: "9fd4b70a1892bec00906d5dedf5ebea6",
  adminSignUrl: "serveradmin/serverAdmin/",
  adminServerUrl: "/dev/tm/serveradmin/serverAdmin/",
  rootUrl: "/",
  indexUrl: "/index.html"
};

$.cinit(configs);

/**
 * 签名配置信息
 * @type {{url: string, signUrl: string}}
 */
var signConfig = {
  url: "/dev/tm/serveradmin/serverAdmin/",
  signUrl: "serveradmin/serverAdmin/"
};

$.sinit(signConfig);

/**
 * -----------------------------------------------
 * 应用公共方法
 * -----------------------------------------------
 */
if(typeof jQuery === "undefined"){
  throw new Error("jQuery 类库找不到！");
};

+function($){
  $.extend({
    createClientId: createClientId
  });

  /**
   * 生成clientId
   * @param clientId
   * @returns {*}
   */
  function createClientId(clientId){
    if(!clientId){
      var range = 9999999999999999 - 1000000000000000;
      var rand = Math.random();
      clientId = 1000000000000000 + Math.round(rand * range);
    }
    return clientId;
  }
}(jQuery);



